package mz.co.research.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.i18n.client.Constants;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Example file.
 */
public class CwWelcome extends ContentWidget {
	/**
	 * The constants used in this Content Widget.
	 */
	public static interface CwConstants extends Constants {
		String cwWelcomeName();

		String cwWelcomeDescription();
	}

	/**
	 * An instance of the constants.
	 */
	private final CwConstants constants;

	/**
	 * Constructor.
	 * 
	 * @param constants
	 *            the constants
	 */
	public CwWelcome(CwConstants constants) {
		super(constants.cwWelcomeName(), constants.cwWelcomeDescription(), true);
		this.constants = constants;
	}

	@Override
	public Widget onInitialize() {
		// Welcome a vertical panel to align the check boxes
		VerticalPanel vPanel = new VerticalPanel();

		HTML label = new HTML(constants.cwWelcomeName());
		Label l = new Label("Vamos testar isso");

		vPanel.add(label);
		vPanel.add(l);

		return vPanel;
	}

	@Override
	protected void asyncOnInitialize(final AsyncCallback<Widget> callback) {
		GWT.runAsync(CwWelcome.class, new RunAsyncCallback() {

			public void onFailure(Throwable caught) {
				callback.onFailure(caught);
			}

			public void onSuccess() {
				callback.onSuccess(onInitialize());
			}
		});
	}
}
